---
layout: "default"
title: "HalfOpenInterval"
description: "Swift documentation for 'HalfOpenInterval': A half-open IntervalType, which contains its start but not its."
keywords: "HalfOpenInterval,struct,swift,documentation,clamp,contains,getMirror,debugDescription,description,end,isEmpty,start,Bound"
root: "/v1.2"
---

<div class="intro-declaration"><code class="language-swift">struct HalfOpenInterval&lt;T : Comparable&gt;</code></div>

<div class="discussion comment">
    <p>A half-open <code>IntervalType</code>, which contains its <code>start</code> but not its
<code>end</code>.  Can represent an empty interval.</p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">DebugPrintable, Equatable, IntervalType, Printable, Reflectable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Bound = T</code>
<div class="comment">
    <p>The type of the <code>Interval</code>&#39;s endpoints</p>
</div>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_">init(<wbr>_:)</a><div class="comment collapse" id="comment-init_"><div class="p">
    <p>Construct a copy of <code>x</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ x: HalfOpenInterval&lt;T&gt;)</code>

    </div></div>
</div>
<div class="declaration" id="init__">
<a class="toggle-link" data-toggle="collapse" href="#comment-init__">init(<wbr>_:<wbr>_:)</a><div class="comment collapse" id="comment-init__"><div class="p">
    <p>Construct an interval with the given bounds.  Requires: <code>start</code>
&lt;= <code>end</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init(_ start: T, _ end: T)</code>

    </div></div>
</div>


<h3>Instance Variables</h3>
<div class="declaration" id="var-debugdescription_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-debugdescription_-string">var debugDescription: String</a><div class="comment collapse" id="comment-var-debugdescription_-string"><div class="p">
    <p>A textual representation of <code>self</code>, suitable for debugging.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var debugDescription: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-description_-string">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-description_-string">var description: String</a><div class="comment collapse" id="comment-var-description_-string"><div class="p">
    <p>A textual representation of <code>self</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var description: String { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-end_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-end_-t">var end: T</a><div class="comment collapse" id="comment-var-end_-t"><div class="p">
    <p>The <code>Interval</code>&#39;s upper bound. Invariant: <code>start</code> &lt;= <code>end</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">var end: T { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-isempty_-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-isempty_-bool">var isEmpty: Bool</a><div class="comment collapse" id="comment-var-isempty_-bool"><div class="p">
    <p><code>true</code> iff the <code>Interval</code> is empty.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">var isEmpty: Bool { get }</code>

    </div></div>
</div>
<div class="declaration" id="var-start_-t">
<a class="toggle-link" data-toggle="collapse" href="#comment-var-start_-t">var start: T</a><div class="comment collapse" id="comment-var-start_-t"><div class="p">
    <p>The <code>Interval</code>&#39;s lower bound. Invariant: <code>start</code> &lt;= <code>end</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">var start: T { get }</code>

    </div></div>
</div>



<h3>Instance Methods</h3>
<div class="declaration" id="func-clamp_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-clamp_">func clamp(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-clamp_"><div class="p">
    <p>Return <code>intervalToClamp</code> clamped to <code>self</code>.  The bounds of the
result, even if it is empty, are always limited to the bounds of
<code>self</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func clamp(intervalToClamp: HalfOpenInterval&lt;T&gt;) -&gt; HalfOpenInterval&lt;T&gt;</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-contains_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-contains_">func contains(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-contains_"><div class="p">
    <p>Returns <code>true</code> iff the <code>Interval</code> contains <code>x</code></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func contains(x: T) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-getmirror">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-getmirror">func getMirror()</a>
        
<div class="comment collapse" id="comment-func-getmirror"><div class="p">
    <p>Returns a mirror that reflects <code>self</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func getMirror() -&gt; MirrorType</code>
    
    
</div></div>
</div>


